﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using AnimalCare.Model;

namespace AnimalCare.Service
{
    class OrderService
    {
        public static int count()
        {
            int count = 0;
            using (var ctx = new AnimalCareDBEntities())
            {
                foreach (OrderMain o in ctx.OrderMains)
                {
                    count++;
                }
            }
            return count;
        }
        public static void Insert(OrderMain order)
        {
            using (var ctx = new AnimalCareDBEntities())
            {
                ctx.OrderMains.AddObject(order);
                ctx.SaveChanges();
            }
        }

        public static int getOrderId(String orderNumber)
        {
            int id;
            using (var ctx = new AnimalCareDBEntities())
            {
                var order = (from s in ctx.OrderMains
                             where s.oder_number.Equals(orderNumber)
                             select s).SingleOrDefault();
                id = order.order_id;
            }
            return id;
        }
    }
}
